<template>
    <view class="goods_list">
        <goods-list @goodsItemClick="goGoodsDetail" :goods="goods"></goods-list>
        <view class="isOver" v-if="flag">.....</view>
    </view>
</template>
<script>
import goodsList from '../../components/goods-list/goods-list.vue'
export default{
    data(){
        return{
            pageindex:1,
            goods:[],
            flag:false
        }
    },
    copmponents:{'goods-list':goodsList},
    methods:{
        async getGoodsList(callBack){
            const res await this.$myRequest({
                url:"/api/getgoods?pageindex="+this.pageindex
            })
            this.goods = [...this.goods, ...res.data.message]
            callBack && callBack()
        },
        goGoodsDetail(id){
            uni.navigateId({
                url:'/pages/goods-detail/goods-detail?id='+id
            })
        },
        onLoad(){
            this.getGoodsList()
        },
        onReachnottom(){
            if(this.goods.length<this.pageindex*10) return this.flag = true
            this.pageindex++
            this.getGoodsList()
        }
    }
}
</script>